<template>
  <div class="newcomerDiscountPage">
    <div class="header">
      <img src="@/assets/images/left-jt.png" alt="" class="img" @click="backHandle">
      <span>新人优惠</span>
    </div>
    <SeachTable class="seachTable" :noResetTable="true" :tableType="1" ref="searchTableRef" :forms="tableForms" :btnLefts="btnLefts"
        :btnRights="btnRights" :tableLoading="tableLoading" :tableConfig="tableConfig" :tableData="tableData"
        :totalPage="total" @handlerSearch="handlerSearch">
          <template #activityName="{row}">
            <span class="activityName" @click="toDetail(row.id)">
              {{ row.activityName }}
            </span>
          </template>
      </SeachTable>
  </div>
</template>

<script setup>
import { useActivityData } from '../../Hooks/index'
import { useCurd,useNewcomerDiscountData } from './index'
import { useMarketInfoStore } from '@/stores/marketing.js'
const useMarketStore = useMarketInfoStore()
const {
  tableLoading,
  total,
  tableData,
  btnLefts,
  btnRights,
  tableConfig,
  tableForms,
  handlerSearch,
} = useCurd()
const {searchTableRef} = useNewcomerDiscountData()
const router = useRouter()

onMounted(() => {
  searchTableRef.value.handlerSearch()
})
onActivated(() => {
  searchTableRef.value.handlerSearch()
})
const toDetail = (id)=>{
  router.push({name:'NewcomerDiscountDetail',query:{id,view:1}})
}
const {
  isShowNewcomerDiscount
} = useActivityData()
const backHandle = ()=>{
  isShowNewcomerDiscount.value = false
  useMarketStore.setMarketIndex({
      isShowNewcomerDiscount:false,
      isShowDiscountRestriction:true
    })
}
</script>

<style lang="less" scoped>
div{
  box-sizing: border-box;
}
.newcomerDiscountPage{
  height: calc(100%);
}

.header {
  padding-left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  font-size: 16px;
  color: #000;
  font-weight: 600;
  border-bottom: 1px solid #DDD;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(0deg, #FFF 0%, #FFF 100%), #FFF;

  .img {
    cursor: pointer;
    width: 16px;
    height: 16px;
    position: relative;
  }
}
.seachTable{
  height: calc(100% - 50px) !important;
  :deep(.search-table){
    .line-block{
      display: none;
    }
    .btn-area{
      padding-top: 0;
    }
    .search-line{
      padding-top: 16px;
      padding-bottom: 2px;
    }
  }
}
.activityName{
 cursor: pointer;
 color: #3480ff;
 font-size: 14px;
 font-weight: 400;
 line-height: 14px;
}
</style>